
#include "../common.h"
#include<syslog.h>

int main(int argc, char** argv)
{
	/*
	openlog("wltest--:", LOG_PID | LOG_PERROR, LOG_USER);
	syslog(LOG_INFO, "log--me\n");
	closelog();
	*/
	printf("Before turn to a daemon process.\n");
	printf("Current directory: %s\n", getcwd(NULL, 1024));
#ifdef _NOCHROOT_
	daemon(1, 1);
#else
	daemon(0, 0);
#endif
	openlog("[the daemon cwd log]", LOG_PID | LOG_INFO|LOG_PERROR, LOG_USER);
	printf("Now I am a daemon process.\n");
	fprintf(stderr, "A message sent to standard error\n");
	syslog(LOG_INFO, "Current directory: %s.\n", getcwd(NULL,1024));
	//sleep(360);

	return 0;
}
